package metu.tespit.entity.course;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


import metu.tespit.entitiy.accountManagement.User;

/**
 
 * @created 13 Nis 2012
 */

@Entity
@Table(name="projectTeam")
public class ProjectTeam implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7448451204664906035L;

	@Id @GeneratedValue
	private Long id;
	
	private String name;
	
	//TODO: picture
	@OneToMany(mappedBy="projectTeam", cascade = CascadeType.ALL)
	private List<User> students=new ArrayList<User>();
	
	@ManyToOne
	private Course course;

	@OneToMany(cascade = CascadeType.ALL)
	private List<ProjectDocument> projectDocuments = new ArrayList<ProjectDocument>();
	
	@OneToMany(cascade = CascadeType.ALL)
	private List<Activity> incompleteActivities = new ArrayList<Activity>();
	
	public List<ProjectDocument> getProjectDocuments() {
		return projectDocuments;
	}

	public void setProjectDocuments(List<ProjectDocument> projectDocuments) {
		this.projectDocuments = projectDocuments;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<User> getStudents() {
		return students;
	}

	public void setStudents(List<User> students) {
		this.students = students;
	}

	public Course getCourse() {
		return course;
	}

	public void setCourse(Course course) {
		this.course = course;
	}

	public List<Activity> getIncompleteActivities() {
		return incompleteActivities;
	}

	public void setIncompleteActivities(List<Activity> incompleteActivities) {
		this.incompleteActivities = incompleteActivities;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProjectTeam other = (ProjectTeam) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	


}
